<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */

?>
<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/space.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/space_log.js"></script>
<div class="warpper">
	<div class="container">
		<div class="space_show">
			<div class="left"> <img <?php 
			if($follow && (($follow->uid==Yii::app()->user->id && in_array($follow->status,array(1,3)))||($follow->fid==Yii::app()->user->id && in_array($follow->status,array(2,3))))):?>
			src="images/space_gz_do.png"
			<?php else:?>src="images/space_gz.jpg"
			<?php endif;?> 
			width="75" height="47" alt="关注" class="attention"/> <a href="javascript:void(0);" title="发信"><img src="images/space_write.jpg" width="75" height="45" alt="发信" class="transmitter"/></a>
	<div class="show_pic">
		<div class="content_list">
			<div class="showbox"> <a href="#" title="cocoli"><img src="<?php echo Utils::getAvatar($user->avatar);?>" width="180" height="180" alt="cocoli"/></a> </div>
		</div>
	</div>
	<div class="space_pic_infor1">
		<p><span><?php echo CHtml::encode($user->nickname);?>：</span><?php echo $user->sex?User::getSex($user->sex):'保密','，',Utils::getAge($user->birth),'，',Area::getName($user->city_id);?></p>
		<p style="text-indent:1.5em;"><?php if($user->edu){echo User::getDegree($user->edu),'学历，';} ?><?php if($user->income){echo User::getIncome($user->income),'，';};?><?php if($user->height){echo $user->height/100;} ?>m</p>
	</div>

	 <div class="space_pic_infor2">
                        	<p><span>觅友：</span><?php echo $tend->sex_tendency?User::getSex($tend->sex_tendency):'不限','，'; echo $tend->age_start ,'-',$tend->age_end,'岁，',Area::getName($tend->citys_tendency);?></p>
                            <p style="text-indent:1.5em;"><?php if($tend->edu_tendency){echo User::getDegree($tend->edu_tendency),'，';} ?><?php if($tend->income_tendency){echo '月薪',User::getIncome($tend->income_tendency),'，';}?><?php if($tend->height_start){echo $tend->height_start/100,'~';}if($tend->height_end){echo $tend->height_end/100,'m';}else{echo "m以上";}?></p>
                        </div>

	<div class="space_dynamic">
		<div class="top_btn"><img src="images/top_btn.gif" width="14" height="7" alt="上一条"/></div>
		<div class="space_dynamic_list">
			<div class="box_hidden">
				<ul>
					<?php foreach((array)$feed as $v):?>
					
						<p class="time"><?php echo $v[date];?></p>
						<p class="dynamic" style="width: auto;"><?php echo Feed::desc($v['type']);?>：<span class="color406690"><?php echo $v['link'];?></span></p>
					
					<?php endforeach;?>

				</ul>
			</div>
		</div>
		<div class="bottom_btn"><img src="images/bottom_btn.gif" width="14" height="7" alt="下一条"/></div>
	</div>
</div>
<div class="right"> <h1><?php echo CHtml::encode($profile->subject);?></h1>
	<p><h2><?php echo CHtml::encode($profile->title);?></h2></p>
	<p><?php echo CHtml::encode($profile->content);?></p>
</div>
</div>
<div class="space_labels">
	<p>
		<strong>标签：</strong>
		<?php foreach($tags as $v):?>
		<span><?php echo ($v[tag_name]);?></span>
	<?php endforeach;?>
</p>
</div>
<div class="photos">
	<div class="photos_list">
		<ul>
			<?php foreach($pics as $v):?>
			<li>
				<div><img src="<?php echo Utils::getPAth($v->ctime, $v->hash_name);?>" width="135" height="134" alt="<?php echo CHtml::encode($v->title);?>"/></div>
				<p><?php echo CHtml::encode($v->title);?></p>
			</li>
		<?php endforeach;?>
	</ul>
</div>
<div class="photos_btn"> <img src="images/left_btn.gif" width="31" height="55" class="left"/> <img src="images/right_btn.gif" width="31" height="55" class="right"/> </div>
</div>
<div class="infor">
	<div class="inforbase">
		<div class="inforbase_con">
			<ul>
				<?php if($intro->zodiac!=$drop_split):?> 
				<?php if(!$intro)$tmp=array('生肖：','');else $tmp=mb_split($split, $intro->zodiac);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->constellation!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('星座：','');else $tmp=mb_split($split, $intro->constellation);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_colours!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('籍贯：','');else $tmp=mb_split($split, $intro->fav_colours);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->nationality!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('民族：','');else $tmp=mb_split($split, $intro->nationality);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->blood_type!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('血型：','');else $tmp=mb_split($split, $intro->blood_type);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->faith!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('信仰：','');else $tmp=mb_split($split, $intro->faith);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_1!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_1);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_2!=$drop_split):?> 
				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_2);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->weight!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('体　　重：','');else $tmp=mb_split($split, $intro->weight);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->body_size!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('体　　型：','');else $tmp=mb_split($split, $intro->body_size);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_3!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_3);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_4!=$drop_split):?> 
				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_4);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->graduate_school!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('毕业学校：','');else $tmp=mb_split($split, $intro->graduate_school);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->corp!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('公　　司：','');else $tmp=mb_split($split, $intro->corp);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->career!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('从事行业：','');else $tmp=mb_split($split, $intro->career);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->incomes!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('收入情况：','');else $tmp=mb_split($split, $intro->incomes);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_5!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_5);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_6!=$drop_split):?> 
				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_6);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->habits!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('作息习惯：','');else $tmp=mb_split($split, $intro->habits);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->exercising!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('锻炼习惯：','');else $tmp=mb_split($split, $intro->exercising);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->smoke!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('是否吸烟：','');else $tmp=mb_split($split, $intro->smoke);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->drink!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('是否饮酒：','');else $tmp=mb_split($split, $intro->drink);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->personality!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('个性特点：','');else $tmp=mb_split($split, $intro->personality);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->goodat!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('擅长的技能：','');else $tmp=mb_split($split, $intro->goodat);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_7!=$drop_split):?> 
				
				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_7);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->black_8!=$drop_split):?> 
				<?php if(!$intro)$tmp=array('','');else $tmp=mb_split($split, $intro->black_8);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_food!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的食物：','');else $tmp=mb_split($split, $intro->fav_food);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_sports!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的运动：','');else $tmp=mb_split($split, $intro->fav_sports);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fac_moves!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的电影：','');else $tmp=mb_split($split, $intro->fac_moves);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_musics!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的音乐：','');else $tmp=mb_split($split, $intro->fav_musics);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_book!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的书籍：','');else $tmp=mb_split($split, $intro->fav_book);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->fav_product!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('喜欢的产品：','');else $tmp=mb_split($split, $intro->fav_product);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				<?php if($intro->hobby!=$drop_split):?> 

				<?php if(!$intro)$tmp=array('业余爱好：','');else $tmp=mb_split($split, $intro->hobby);?>
				<li><strong><?php echo CHtml::encode($tmp[0]);?></strong><?php echo CHtml::encode($tmp[1]);?></li>
				<?php endif;?>
				
				
			</ul>
			<p><a href="javascript:void(0)" title="查看更多">查看更多</a></p>
		</div>
		<div class="inforbase_title">基<br />
			本<br />
			信<br />
			息</div>
		</div>
		<div class="article">
			<div class="article_title">日<br />
				志</div>
				<div class="article_list">
					<div class="article_con">
						<?php foreach((array)$posts as $v):?>
						<div class="article_box">
							<h2><?php echo CHtml::link(CHtml::encode(mb_substr($v[subject],0,16)).' '.substr($v[ctime], 0,10), 'javascript:void(0)',array('title'=>CHtml::encode($v[subject]),'tag'=>$v[id])),' ',substr($v[mtime],0,10);?>
							</h2>
							<p><?php echo mb_substr(CHtml::encode($v[content]),0,108);?></p>
						</div>
					<?php endforeach;?>
				</div>
				<p><a href="javascript:void(0)" title="查看更多">查看更多</a></p>
			</div>
		</div>
	</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){

//个人空间照片左右单击
var $ani=$(".photos_list").find("ul");
var width2=$ani.find("li").outerWidth(true);
var leng=$ani.find("li").length-5;
$(".photos_btn img.left").mousedown(function(){
	$(this).attr("src","images/left_btn2.gif");
	$ani.find("li:gt("+leng+")").prependTo($ani);
	$ani.css({'left':-width2*4});
	$ani.animate({'left':0});
}).mouseup(function(){
	$(this).attr("src","images/left_btn.gif");
})
$(".photos_btn img.right").mousedown(function(){
	$(this).attr("src","images/right_btn2.gif");
	$ani.animate({'left':-width2*4},function(){
		$ani.find("li:lt(4)").appendTo($ani);
		$ani.css({'left':0})
	})
}).mouseup(function(){
	$(this).attr("src","images/right_btn.gif");
})

	//个人空间标签添加随机颜色
	var arr = new Array();
	$(".space_labels span").each(function(index){
		arr[index]=index;
	})
	var groups = new Array(5);
	var str = "";
	while(arr.length>0){
		var index = Math.ceil(Math.random()*arr.length-1);
		str += arr[index]+",";
		arr.splice(index,1);
	}
	str = str.substring(0, str.length-1);
	arr = str.split(',');
	for(var i=0; i<arr.length;i++){
		var groupIndex = parseInt(i/5);
		if(groups[groupIndex]==null){
			groups[groupIndex] = arr[i];
		}else{
			groups[groupIndex]+=","+parseInt(arr[i]);
		}
		groups[groupIndex]=groups[groupIndex].split(",")
	}
	for(var i=0;i<parseInt(arr.length/5);i++){
		$.each(groups[i],function(n,value) { 
			var font="font"+i;
			$(".space_labels span").eq(value).addClass(font);
		}); 
	}
		//展示好友动态
		var i=j=0;
		var len=$(".box_hidden li").length;
		var height=$(".box_hidden li").outerHeight(true);
		$(".space_dynamic .top_btn").click(function(){
			if(j<0){
				$(".box_hidden ul").animate({"top":(j+1)*height},function(){
					j++;
					i=j;
				});
			}
		})
		$(".space_dynamic .bottom_btn").click(function(){
			i--;
			if(i>=4-len){
				$(".box_hidden ul").animate({"top":i*height},function(){
					j=i;
				});
			}			
		})
		
	//关注好友
	$("img.attention").click(function(){
		if($("img.attention").attr("src")=="images/space_gz_do.png")return false;
		$.post('?r=space/follow&id=<?php echo $_GET[id];?>',{id:<?php echo $_GET['id']?$_GET['id']:Yii::app()->user->id;?>},function(data){
			data = $.parseJSON(data);
			if(data.status=='0'){
				$("img.attention").attr("src","images/space_gz_do.png");
			}
			$('#topmsg').html(data.desc);
			$('#showmsg').show();
			showDialog();
			setTimeout(function(){$('#showmsg').hide();},1000);
			
			
		});
		
	})


	$('.transmitter').click(function(){
		var msg='';
		<?php if(Yii::app()->user->isGuest):?>
			msg = '请登陆后再操作';
		<?php else:?>
		<?php if($_GET['id']==Yii::app()->user->id||empty($_GET['id'])):?>
			msg ='不能给自己写信';
		<?php endif;?>
		<?php endif;?>
			if(msg){
				$('#topmsg').html(msg);
				$('#showmsg').show();
				showDialog();
				setTimeout(function(){$('#showmsg').hide();},1000);
				return false;
			}else
			window.location.href="?r=pm/new&tid=<?php echo $_GET[id]?>";

	})


	//个人空间日志列表弹出
	$(".article_list p a").live("click",function(){
		space_log("?r=space/blog&id=<?php echo $_GET['id'];?>");
		show_log();
	})

	//个人空间日志弹出
	$(".article_list h2 a").live("click",function(){
		space_log("?r=space/blogview&id="+$(this).attr('tag'));
		show_log();
	});

//个人空间日志弹出2
	$(".article_zee").live("click",function(){
		space_log("?r=space/blogview&id="+$(this).attr('tag'));
		show_log();
	});

	function space_log(option){
		$("body").prepend("<div class='space_log_bg'></div><div class='spacelog'><div class='position' ><div class='log_topbtn'></div><div class='log_content'></div><div class='log_bottombtn'></div><div class='close'></div><a class='close_x' href='javascript:void(0)'>X</a></div></div>");
		$(".log_content").load(option);
	}
	function show_log(){
		spaceDialog();
		$(".space_log_bg,.spacelog").show();
		$(".log_topbtn").hover(function(e) {
			$(this).toggleClass("log_topbtn_hover");
		});
		$(".log_bottombtn").hover(function(e) {
			$(this).toggleClass("log_bottombtn_hover");
		});
		$("a.close_x").click(function(){
			$(".space_log_bg").remove();
			$(".spacelog").remove();
		})
	}
	function spaceDialog(){
		var brsW=$(window).width();
		var brsH=$(window).height();
		var curW=$(".spacelog").width();
		var curH=$(".spacelog").height();
		var left=(brsW-curW)/2;
		var top=(brsH-curH)/2;
		$(".space_log_bg").css({ "height": $("body").height()});
		$(".spacelog").css({ "top": top,"left": left });
		if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
			$(".spacelog").css({ 'top': $(document).scrollTop() + top});
			$(window).scroll(function () {
				$(".spacelog").css({ 'top': $(document).scrollTop() + top});
			});
		}
	}	


})
</script>